home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / border / LineBorder.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  1.8 KB  |  81 lines

  1. package javax.swing.border;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Component;
  5. import java.awt.Graphics;
  6. import java.awt.Insets;
  7.  
  8. public class LineBorder extends AbstractBorder {
  9.    private static Border blackLine;
  10.    private static Border grayLine;
  11.    protected int thickness;
  12.    protected Color lineColor;
  13.    protected boolean roundedCorners;
  14.  
  15.    public LineBorder(Color var1) {
  16.       this(var1, 1, false);
  17.    }
  18.  
  19.    public LineBorder(Color var1, int var2) {
  20.       this(var1, var2, false);
  21.    }
  22.  
  23.    LineBorder(Color var1, int var2, boolean var3) {
  24.       this.lineColor = var1;
  25.       this.thickness = var2;
  26.       this.roundedCorners = var3;
  27.    }
  28.  
  29.    public static Border createBlackLineBorder() {
  30.       if (blackLine == null) {
  31.          blackLine = new LineBorder(Color.black, 1);
  32.       }
  33.  
  34.       return blackLine;
  35.    }
  36.  
  37.    public static Border createGrayLineBorder() {
  38.       if (grayLine == null) {
  39.          grayLine = new LineBorder(Color.gray, 1);
  40.       }
  41.  
  42.       return grayLine;
  43.    }
  44.  
  45.    public Insets getBorderInsets(Component var1) {
  46.       return new Insets(this.thickness, this.thickness, this.thickness, this.thickness);
  47.    }
  48.  
  49.    public Insets getBorderInsets(Component var1, Insets var2) {
  50.       var2.left = var2.top = var2.right = var2.bottom = this.thickness;
  51.       return var2;
  52.    }
  53.  
  54.    public Color getLineColor() {
  55.       return this.lineColor;
  56.    }
  57.  
  58.    public int getThickness() {
  59.       return this.thickness;
  60.    }
  61.  
  62.    public boolean isBorderOpaque() {
  63.       return true;
  64.    }
  65.  
  66.    public void paintBorder(Component var1, Graphics var2, int var3, int var4, int var5, int var6) {
  67.       Color var7 = var2.getColor();
  68.       var2.setColor(this.lineColor);
  69.  
  70.       for(int var8 = 0; var8 < this.thickness; ++var8) {
  71.          if (!this.roundedCorners) {
  72.             var2.drawRect(var3 + var8, var4 + var8, var5 - var8 - var8 - 1, var6 - var8 - var8 - 1);
  73.          } else {
  74.             var2.drawRoundRect(var3 + var8, var4 + var8, var5 - var8 - var8 - 1, var6 - var8 - var8 - 1, this.thickness, this.thickness);
  75.          }
  76.       }
  77.  
  78.       var2.setColor(var7);
  79.    }
  80. }
  81.